package com.rd.student.ruanjian.class1.duhang.Week04.New01;

public class Test02 extends Thread{
    public static void main(String[] args) {
        Test02 test02 = new Test02();
        new Thread(test02::shuzi).start();
        new Thread(test02::zimu).start();
    }

    public synchronized void shuzi(){
        for (int i = 1; i <= 52; i++) {
            System.out.print(i);
            if (i % 2 == 0){
                notify();
                try {
                    wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public synchronized void zimu(){
        for (char i = 'A'; i <= 'Z'; i++) {
            System.out.print(i);
            notify();
            try {
                this.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
